const Koa = require('koa')
const app = new Koa()
const json = require('koa-json')//美化JSON
const bodyparser = require('koa-bodyparser')
const koaBody = require('koa-body')
const logger = require('koa-logger')
const InitManager = require('./core/init')
var cors = require('koa2-cors');
app.use(cors());
app.use(bodyparser({
  enableTypes: ['json', 'form', 'text']
}))
app.use(json())
app.use(logger())
app.use(async (ctx, next) => {
  ctx.data = {
    a: 1
  }
  await next();
})
InitManager.initCore(app)
app.use(async (ctx, next) => {

  console.log('end', ctx.data)
  ctx.body = ctx.data

})
module.exports = app
